from pymongo import MongoClient
import re
# client = MongoClient()
client = MongoClient('192.168.0.220', 27017)
db = client['tjdb']
collection = db['directory']
# collection = db['Data']
pmap=[]
for each in collection.find({}):
    name = re.findall(r'(.*?)统计年鉴',each['name'])
    mm={}
    mm['name']=name[0]
    num = 0
    print(type(each['years']))
    for temp,y in each['years'].items():
        # print(y)
        for k,v in y.items():
            num+=len(v)
    mm['value']=num
    pmap.append((mm))
print(pmap)